package com.sunyy.codegenerator.util;

import cn.hutool.core.lang.Snowflake;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

/**
 * @author sunyy
 * @date 2025/1/24
 */
@Component
public class SnowflakeUtil {
    private static Snowflake snowflake;

    public SnowflakeUtil(@Qualifier("snowflake") Snowflake snowflake) {
        SnowflakeUtil.snowflake = snowflake;
    }

    /**
     * 获取id
     *
     * @return id
     */
    public static long getId() {
        return snowflake.nextId();
    }

}
